import request from "@/utils/Request";

export default class BlogCommonApi {
  // 登出
  async logOutUser() {
    return Promise.resolve(request.get("/api/logout"));
  }

  // 获取文章列表
  async getArticleList(data) {
    return Promise.resolve(request.get("/api/article/list", data));
  }

  //根据分类id查询文章分页列表
  async getArticleListByClassifyId(data) {
    return Promise.resolve(
      request.get("/api/classify/classifyShow/byId", data)
    );
  }

  async getArticleListByTagId(data) {
    return Promise.resolve(request.get("/api/tag/tagByIdToArticle", data));
  }

  //获取文章数量
  async getAriCount() {
    return Promise.resolve(request.get("/api/article/listCount"));
  }

  //获取分类列表
  async getClassifyList() {
    return Promise.resolve(request.get("/api/classify/list"));
  }

  //获取标签列表
  async getTagList() {
    return Promise.resolve(request.get("/api/tag/list"));
  }

  // 上传文章图片
  async uploadArticleImageFile(file) {
    return Promise.resolve(request.postForm("/api/article/image", file));
  }

  // 上传markdown图片
  async uploadMarkdownImageFile(file) {
    return Promise.resolve(
      request.postForm("/api/article/markdown/image", file)
    );
  }

  //上传用户头像
  async uploadUserAvatar(file) {
    return Promise.resolve(request.postForm("/api/user/update/avatar", file));
  }

  // 留言页面添加留言信息
  async addMessage(data) {
    return Promise.resolve(request.postForm("/api/message/add", data));
  }

  // 留言页面获取留言信息
  async getMessageList() {
    return Promise.resolve(request.get("/api/message/getMsgList"));
  }

  // 获取聊天室聊天信息
  async getChatRoomRecord() {
    return Promise.resolve(request.get("/api/websocket/record"));
  }
}
